package com.dmitriyp.movie.console.actions;

import static java.lang.System.out;

import com.dmitriyp.movie.console.AbstractUserAction;
import com.dmitriyp.movie.console.UserInputUtil;
import com.dmitriyp.movie.dao.IMovieManager;
import com.dmitriyp.movie.mapping.Movie;

public class UserViewAction extends AbstractUserAction {

    public UserViewAction(IMovieManager manager) {
        super(manager);
    }

    public void doAction() {
        out.println("Enter Movie's Id");
        int id = UserInputUtil.readInt(scanner);
        Movie movie = getManager().get(id);
        if (movie == null) {
            out.println("Movie with Id \'" + id + "\' does not exist.");
            return;
        }
        out.println("Movie: " + movie.getTitle());
        out.println("Year: " + movie.getReleaseYear());
        out.println("Format: " + movie.getFormat());
        out.println("Stars: " + movie.getStars());
        out.println();
        UserInputUtil.pressAnyKey();
    }

}
